Generic unpacking of applications for malware detection

ABSTRACT

A technique for detecting malware in an executable allows unpacking of a packed executable before determining whether the executable is malware. In systems with hardware assisted virtualization, hardware virtualization features may be used to iteratively unpack a packed executable in a controlled manner without needing knowledge of a packing technique. Once the executable is completely unpacked, malware detection techniques, such as signature scanning, may be employed to determine whether the executable contains malware. Hardware assisted virtualization may be used to facilitate the scanning of the run-time executable in memory.

TECHNICAL FIELD

This disclosure relates generally to a system and method to unpackexecutable binaries such that less reliance is placed on multiplesignatures (e.g., one for each packing method) to identify potentialmalware being maintained in virus signature DAT files. Moreparticularly, but not by way of limitation, this disclosure relates tousing hardware-assisted virtualization when unpacking a packedexecutable file to determine its original entry point and, prior toexecution of original entry point, performing a formal scan of theexecutable once it reaches its fully expanded form.

BACKGROUND

Contemporary delivery of application code typically involves itscompression through a packing process. By using a packing process,binary file sizes may be reduced, and multiple files may be combinedinto one file. Modern packing processes create “self-extractingexecutables,” which may be executed to unpack the contents of the packedcode. That is, the packed code itself is accompanied by an executablecode section that, when executed, results in inflating or uncompressingthe packed code. Accordingly, running a self-extracting executable canresult in the packed code executable being expanded on disk, in memory,or both.

When packing a file to create a self-extracting executable, manydifferent types of compression algorithms and packing techniques may beemployed. Some of these are well-known and documented while others arenot. Employing different techniques on the same file to create aself-extracting executable will result in different files—both thepacking code and the packed code may be different because of differentpackers and varying results from different compression algorithms.Further, if unknown or undocumented techniques are used to pack the fileinto a self-extracting executable, it may be difficult to even determinethe distinction between the packing code and the packed code.

These characteristics of self-extracting executables are often exploitedby malware developers to hide malware from antivirus programs or malwaredetection programs. One common method to detect malware is signaturescanning. With signature scanning, files are scanned for bit patterns,or signatures, that are known or suspected to be associated withmalware. When a bit pattern in a file matches a signature of knownmalware, then that file can be identified as being, or containing,malware. However, a signature of a malicious executable can be easilychanged in an effort to obfuscate the executable. When malware ispacked, detection may be avoided because the known signature of theunpacked malware will not match any bit pattern of the packed malwarefile.

To attempt to overcome these efforts to hide malware, antivirus programsand malware detection programs may employ multiple techniques. Onetechnique is to extract the packed code in memory without executing itand then attempt to scan the uncompressed binary for malware signatures.Packed code may be extracted by emulating its execution or, if thepacking algorithm is known, performing the extraction by the antivirusprogram. If the packing technique is not well-known or documented,extracting the packed code under the control of the antivirus programmay not be possible. Also, many packing algorithms use anti-emulationand anti-debugging techniques to simply terminate the unpacking processafter detecting that the unpacking is being performed by a debugger orthrough execution emulation. Time stamping parts of the code flow is astandard method that may be used to determine that code is beingemulated. Similarly, identifying that code is being debugged may beeasily determined by inquiring to the operating system.

Even if the self-extracting executable is allowed to execute or beemulated, an antivirus program may have difficulty in determining whenthe unpacking part of execution is complete and when the originallycompressed executable begins execution. In a self-extracting executable,the unpacking code and the packed executable are part of the samebinary, and determining the distinction between the two in memory can bedifficult.

Another technique to overcome the efforts to hide malware is to addsignatures of known self-extracting executables which contain malwareinto an antivirus signature database once such a new signature of packedmalware is identified. A weakness to this technique is that it may beeasily avoided by slightly altering the packer code or the packingtechnique, resulting in a different self-extracting executable, and thusa different signature. Adding signatures accounting for these variationsin packing techniques to the antivirus signature database serves toincrease the size of the signature database. This causes a problem inthat the number of signatures and the difficulty of maintaining ofsignature files can correspondingly increase. Further, these efforts maybe further thwarted because the packing process can be repeated anynumber of times using different packing algorithms in different orders,creating an even greater number of signatures to identify and maintain.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram 100 illustrating a simplified structure of anexecutable file 101 and a compressed self-extracting executable 102(presumably of smaller size) as known in the prior art.

FIG. 2 is a block diagram illustrating a network architecture 300capable of being configured to facilitate one or more disclosedembodiments.

FIG. 3 is a block diagram illustrating a computer with a processing unitwhich could be configured according to one or more disclosedembodiments.

FIG. 4 is a block diagram illustrating a software stack of a computersystem with a virtual machine monitor, guest operating systems, andapplications.

FIG. 5 is a flowchart illustrating a technique to generically unpack anexecutable until no further unpacking is required according to one ormore disclosed embodiments.

FIG. 6A is a flowchart illustrating a technique to set memory pagepermissions and address memory page permission violations to controlmemory access to pages of memory during the generic unpacking andexecution phases of an executable according to one or more disclosedembodiments.

FIG. 6B illustrates state diagram 650, which shows the state transitionsfor the controlled execution of an executable from its binary load timeto the termination of its execution.

FIG. 7 is a block diagram illustrating various stages of page memorypermissions seen during the generic unpacking and execution phases of anexecutable according to one or more disclosed embodiments.

DETAILED DESCRIPTION

As explained above, the availability of different packers and the factthat an executable can be packed multiple times result in makingidentification of a packed malicious executable by comparing it to asignature difficult. Each identified variant of a packed maliciousexecutable might need its own signature in a virus signature database ofan antivirus program. This causes virus signature databases to grow andincreases maintenance costs and efforts—the signature file updates mustbe communicated to and downloaded by end-user computers utilizing theantivirus program. Further, determining when to apply a signaturedetection algorithm is complicated by these same factors.

As also explained above, attempting to unpack a packed file to exposethe original executable presents challenges as well. Because theunpacking code is combined with the packed executable, it may bedifficult to identify the moment at which the unpacking code completesexecution and the original binary begins execution. In order to avoidexecution of the original executable, the antivirus program may attemptto unpack the packed executable, rather than letting the unpacker codeexecute. To do this, the antivirus program must be equipped with theunpacking algorithm used to pack the executable. When unknown orundocumented packing techniques are utilized, however, the antivirusprogram may not be able to unpack the software. In these types ofinstances, the antivirus software must be updated by including theunpacker algorithm. Because unpacker algorithms may be sophisticated, itmay take considerable time—months or years—for antivirus softwaredevelopers to incorporate solutions for newly discovered packingalgorithms. Further, these efforts could be circumvented or made moreonerous by even slight alterations to the packer algorithm.

As explained further below, techniques are disclosed to address theseand other problems by using systems and methods to generically unpack asingly or multiply packed application in a controlled manner to detectmalware. Generically unpacking a packed application allows theapplication to be unpacked independent of knowledge of the unpackingalgorithm and independent of knowledge of the implementation of theunpacking stub. Functionality associated with hardware-assistedvirtualization may be utilized to help generically unpack the packedapplication in a controlled manner. These techniques may reduce oreliminate the need to maintain a plurality of signatures for a singletype of malware.

Referring to FIG. 1, block diagram 100 illustrates the internal sectionswithin two files—an executable file and a packed version of that fileaccording to the prior art. Generic executable 101 represents anexecutable binary in expanded (i.e., run-time) form. Packed executable102, which is the result of the generic executable 101 being modifiedthrough a packing process, is also illustrated. Executable 101 may havebeen created by a developer performing a compile and link process onsource code, object files, and libraries. Executable 101 may beorganized into three different sections. Binary header 105 holdsinformation about the organization of the rest of the executable binary,including code section(s) 110 and data section(s) 115. Binary header 105also includes memory permissions for all the sections included in filewhich will be enforced by an operating system loader when the executable101 is loaded into memory. When loaded into memory, each section startsat a boundary of a memory page that is defined by the operating system.A section from the file does not have to only encompass one memorypage—rather, each section can span an integral number of pages.

Program execution starts (i.e., run-time) from a location within one ofthe code sections in an executable binary 101 that is commonly referredto as the “Entry Point” of a program. The Entry Point can be anywhere inthe code section depending on where compiler/assembler has put the‘main’ function in a binary. The Entry Point does not need to start onthe start of any particular code section, which also means that theEntry Point does not necessarily start at the start of any particularmemory page.

A packer can pack and compress executable file 101 to create a packedexecutable file 102 via what is referred to herein as a packing process.Typical packers can perform complex and unique operations, but almostall packers perform a relatively simple set of operations when viewedfrom a high level, as will be described here. In creating packedexecutable 102, the packer process compresses the code section(s) 110and data section(s) 115 of executable 101 using a compression algorithmon the sections. This is typically primarily performed in an effort toreduce the file size of the executable, but, as in the case of malware,it may be performed primarily to change the signature of the malware.Once the sections are compressed, they can be placed in a new section,packed code and data 135, in packed executable file 102. Alternatively,packers may also pack the code and data into the same section in whichthe unpacking code is contained. Thus, the packer code section 130 andpacked code and data 135 may be in separate sections or in one section.

The packing process also typically creates a virtual code section 125with a predetermined size that it will take in memory when executed.This size is typically calculated to be greater than or equal to thesize of the uncompressed packed code and data 135, as it would be foundin original executable 101. Because virtual code section 125 is asection intended for uncompressed data in memory, it does notnecessarily occupy any space in the packed executable 102 itself.Rather, its size in the file containing the packed executable 102 may bereflected as a number of memory pages needed in memory prior toexecution of the uncompress process of the packer code. The details ofthe virtual code section 125 are specified in the changed binary header120 by packer conversion code. When a binary executable will be loadedinto memory by an operating system, the number of memory pages that aparticular section will take in memory is also typically specified in abinary header (e.g., 105 or 120). So, even if a section size on anexecutable file on disk is zero, that section may take some space inmemory when loaded by an operating system. Thus, the packing process hasreduced the size of the whole binary file (i.e., disk size and downloadsize) by compressing the code and data but has made provision foradequate memory to hold the uncompressed code and data when unpackedinto memory at execution.

Alternatively, rather than using a virtual code section 125, theunpacker stub that resides in packer code section 130 can allocatesufficient process memory during execution to hold the uncompressed codeand data while unpacking in memory. However, the unpacker stub muststill mark these memory pages as executable to execute them, and thismay be monitored. Therefore, once execution starts, if memory pages areallocated with execution permissions, these memory pages may beidentified as possibly containing uncompressed code and data. If thistechnique for memory allocation is used, the allocated memory range canbe identified by monitoring memory allocation, and the allocated memoryrange may be treated as virtual code section 125. Because most packersemploy the technique of using virtual code section 125 as a placeholderfor uncompressed code and data, this technique is referenced in theexamples below.

Packer code section 130 is a new code section added in packed executable102 that contains the run-time unpacker stub code. This unpacker stubwill read packed code and data from packed code and data section 135,uncompress it, and place it in virtual code section 125. Morespecifically, the uncompressed code can be placed into the memoryallocated to hold the virtual code section. During the original packingprocess the binary header 105 is modified to binary header 120 to makesure that the Entry Point field of the header will invoke the unpackerstub in packer code section 135.

The packing, transmission, and subsequent unpacking of an executable maybe performed in the context of a network infrastructure. Referring nowto FIG. 2, infrastructure 200 is shown schematically. Infrastructure 200contains computer networks 202. Computer networks 202 include manydifferent types of computer networks available today such as theInternet, a corporate network or a Local Area Network (LAN). Each ofthese networks can contain wired or wireless devices and operate usingany number of network protocols (e.g., TCP/IP). Networks 202 areconnected to gateways and routers (represented by 208), end usercomputers 206 and computer servers 204. Also shown in infrastructure 200is cellular network 203 for use with cellular communication. As is knownin the art, cellular networks support cell phones and many other typesof devices (e.g., tablet computers not shown). Cellular devices in theinfrastructure 200 are illustrated as cell phones 210. Any of thedevices shown in infrastructure 200 could attempt to execute aself-extracting executable. If the processor of the device includes therequired capabilities, the concepts of this disclosure could beimplemented therein. Infrastructure 200 is illustrative and by way ofexample only, and other infrastructures can be employed in the disclosedtechniques as desired.

Referring now to FIG. 3, an example processing device 300 for use in thedisclosed techniques according to various embodiments is illustrated inblock diagram form. Processing device 300 may be implemented in variousdevices, such as in a cellular phone 210, a gateway or router 208, aclient computer 206, or a server computer 204. Example processing device300 comprises a system unit 305 which may be optionally connected to aninput device 330 (e.g., keyboard, mouse, touch screen, etc.) and display335. A program storage device (PSD) 340 (sometimes referred to as a harddisc, flash memory, or computer-readable medium) is included with thesystem unit 305. Also included with system unit 305 may be a networkinterface 320 for communication via a network (such as cellular network203 or computer network 202) with other computing and corporateinfrastructure devices (not shown) or other cellular communicationdevices. Network interface 320 may be included within system unit 305 orbe external to system unit 305. In either case, system unit 305 iscommunicatively coupled to network interface 320. Program storage device340 represents any form of non-volatile storage including, but notlimited to, all forms of optical and magnetic memory, includingsolid-state, storage elements, including removable media, and may beincluded within system unit 305 or be external to system unit 305.Program storage device 340 may be used for storage of software tocontrol system unit 305, data for use by the processing device 300, orboth.

System unit 305 may be programmed to perform methods in accordance withthis disclosure. System unit 305 comprises one or more processing units(represented by processing unit, or processor, 310), input-output (I/O)bus 325, and memory 315. Memory 315 may be accessed using thecommunication bus 325. Processing unit 310 may include any programmablecontroller device including, for example, a mainframe processor, acellular phone processor, or one or more members of the INTEL® ATOM™,INTEL® CORE™, PENTIUM® and CELERON® processor families from IntelCorporation and the Cortex and ARM processor families from ARM. (INTEL,INTEL ATOM, CORE, PENTIUM, and CELERON are trademarks of the IntelCorporation. CORTEX is a registered trademark of the ARM LimitedCorporation. ARM is a registered trademark of the ARM Limited Company).Memory 315 may include one or more memory modules and comprise randomaccess memory (RAM), read only memory (ROM), programmable read onlymemory (PROM), programmable read-write memory, and solid-state memory.Processing unit 310 may also include some internal memory including, forexample, cache memory or memory dedicated to a particular processingunit and isolated from other processing units for use in unpacking anexecutable binary.

Processing device 300 may have resident thereon any desired operatingsystem. Embodiments of disclosed detection techniques may be implementedusing any desired programming language, and may be implemented as one ormore executable programs, which may link to external libraries ofexecutable routines that may be supplied by the provider of thedetection software/firmware, the provider of the operating system, orany other desired provider of suitable library routines. As used herein,the term “a computer system” can refer to a single computer or aplurality of computers working together to perform the functiondescribed as being performed on or by a computer system.

In preparation for performing disclosed embodiments on processing device300, program instructions to configure processing device 300 to performdisclosed embodiments may be provided stored on any type ofnon-transitory computer-readable media, or may be downloaded from aserver 204 onto program storage device 340. Even though a singleprocessing device 300 is illustrated in FIG. 4, any number of processingdevices 300 may be used in a device configured according to disclosedembodiments.

Hardware-Assisted Virtualization

Virtualization is a feature which allows a computer system or device torun multiple operating systems in parallel without making anymodification in operating system code. This type of virtualization maybe differentiated from paravirtualization, which requires modificationsto the hosted operating systems. Many recent consumer-based executionprocessors support hardware-assisted virtualization. Referring to FIG.4, the Virtual Machine Monitor (VMM) 420, which may also be known as ahypervisor layer, is a software layer that resides between the systemhardware 410 (which may, for example, be the processing device 300 fromFIG. 3) and the one or more operating systems (“OS” or “OSes”) 430. Onvirtualized systems, an OS 430 may be called a “guest” OS 430. Onsystems that do not employ virtualization, an OS 430 typicallyinterfaces directly with the hardware 410. When virtualization is used,an OS 430 interfaces with the hardware 410 through the VMM 420. The VMM420 is able to support multiple OSes (such as the three OSes 430illustrated in FIG. 4), and assign to each OS 430 dedicated or sharedaccess to the system resources. In this way, each OS 430 may runconcurrently with the other OSes 430. Further, each OS 430 may runmultiple applications, such as applications 440 illustrated running onOS 430 in FIG. 4.

On systems without virtualization, an OS kernel typically executes at ahighest privilege level, above other software executing on the system.With virtualization, the VMM 420 may utilize hardware virtualizationfeatures of processor and runs at a privilege even above the OS kernel.With hardware-assisted virtualization, memory page access permissionsmay be enforced by the VMM 420. Accordingly, the VMM 420 is able to setRead/Write/Execute permissions on physical memory pages. Each memorypage may be defined to allow/disallow read, write, and executeprivileges. The permissions are set by VMM 420 for an OS 430 executingon the system. If the OS 430 violates the permissions for a given memorypage, control is transferred immediately to a predefined location in theVMM 420 while suspending that OS 430. VMM 420 may be equipped with ageneric unpacker 422, which will help analyze, categorize, and scan therun-time executable in memory upon page permission violations. Genericunpacker 422 may contain a heuristics engine 424, a scanner 426, and adatabase or memory containing heuristics statistics data 428.

When access to a memory page is requested by the OS 430, the processor310 will check the memory page permissions before permitting therequested type of access. Accordingly, the processor 310 does not allowany execution from a memory page if the page does not have executionpermissions set. While compiling a program, a programmer canspecifically set other permissions for the pages of a section, such asby using compiler directives. Referring again to FIG. 1, code section(s)110 are required to at least have read and execute permissions set fortheir memory pages. If not, at run-time, the executable 101 may generatedata execution prevention faults on the executing processor if dataexecution protection is enabled. Data section(s) 115 are required tohave at least read permission set for their pages when loaded in memory.However, both read and write permissions may be set for data sections.

Generic Unpacking Using Hardware-Assisted Virtualization

In order to provide a flexible solution that works across multiplepackers and packing algorithms—known or unknown—and limit thedifficulties associated with unpacking a packed executable, a controlledmethod allows generically unpacking a packed executable without specificknowledge of the unpacker or unpacking algorithm. FIG. 5 demonstrates amethod 500 in which a packed executable is delivered to a targetcomputer and begins execution. At 505, the self-extracting executablefile arrives at the target machine in a packed or iteratively-packedformat. At this point the file may be scanned against known signaturesat 510 to see if it matches any known malware. As described above,however, malware detection at this point may be unsuccessful against anyunidentified packed executables. At 515, the file begins execution. Atthis point, the unpacker code segment of the binary (e.g., packer codesection 130 from FIG. 1) begins execution. At 520, the unpacking processcontinues. If the file has been iteratively packed, then it must beiteratively unpacked, as shown at 525. After this unpacking process hasbeen completed, the original executable of the binary is exposed. Asshown at 530, at this point, at which the unpacker code has completedexecution and the original executable has not yet started execution,another signature scan may be performed. In other words, as shown atpoint 530, generic unpacking would allow the packed executable toexecute and prevent execution before or just before control istransferred to the Original Entry Point (“OEP”) of the originalexecutable, shown at 535. The Original Entry Point is the Entry Point asspecified in binary header of the executable binary when it was in itsoriginal unpacked form. As noted above, emulated execution may be usedto arrive at this point, but there are many packers which containanti-emulation code that prevents the unpacking process from furtherexecuting after detecting that the packer code is being emulated.

Techniques are described below to using hardware-assisted virtualizationto allow a packed executable to execute in controlled manner whileperforming scanning of the executable in memory at regular intervalsusing heuristics to identify and scan the unpacked executable justbefore control is transferred to the OEP. In systems without hardwarevirtualization features, or where hardware virtualization features werenot enabled, these techniques might still be used and implemented insoftware if a privilege level higher than the OS privilege level exists.

Controlled Execution of Binary: Hardware-Assisted Virtualization

Catching malware just before control is transferred to the OEP is a goalof any generic unpacking solution. To arrive at this point, theunpacking code is executed in a controlled manner, and the memory spaceof the executable is scanned and compared against signatures at regularintervals.

Controlled execution may be attained with hardware-assistedvirtualization. As discussed above, the VMM 420, which executes at thehighest privilege level, can set read/write/execute (R/W/X) accessprotections at a page-level granularity for OS page accesses. Thismechanism of setting memory protections on OS pages for OS accesses canbe used to set protections on sections of the packed executable and itsassociated memory. Whenever page access permission violations occur, theVMM 420 gains control of execution and can check heuristically if theOEP transfer is going to happen or if sufficient unpacking has happened.At this point, scanning against malware signatures may be performed, orother malware detection techniques may be performed.

To make a heuristic determination regarding the transfer to the OEP, thegeneric unpacking process needs to control the execution of the binaryat key intervals. These key intervals may be defined as follows. BinaryLoad Time may be defined as the time at which the target packedexecutable binary is loaded in memory and execution has not yet started.Entry Point Execution Violation Time may be defined as the time at whichthe control of execution is transferred to the Entry Point of the packedbinary. A Write Violation Time may be defined as the time at which anattempt is made to write to pages marked by VMM 420 as executable andreadable (but not writeable). Page Execution Violation Time may bedefined as the time at which an attempt is made to execute instructionsfrom pages marked by VMM 420 as readable and writable (but notexecutable).

Referring to FIG. 6A, diagram 600 demonstrates a method to controlexecution of a self-extracting executable. At Binary Load Time 605, allthe sections in the header of the packed executable binary are parsed.At 610, where sections are marked as executable and writable (RWX) inthe binary header, permissions of read and execute (R_X) are assignedusing the VMM 420 on pages associated with that section in memory. Writepermissions are removed for these pages. “RWX” and “R_X” are examples ofa notation indicating the setting of one or more read, write, andexecute permissions. If pages of these sections attempt to execute at afuture time without being written onto, no flag should be raised.However, if a page from one of these sections executes after beingwritten onto, there is a possibility that it is the original unpackedcode which is being executed. This is because the original code may havebeen written into the memory page during the unpacking process (i.e.,the write access), and subsequent execution might indicate that theoriginal executable is executing. In a situation where a file has beenpacked multiple times, the write may be to write that the next layer ofunpacking code into the memory page, and thus subsequent execution wouldnot be that of the original executable, but of an iteration of unpackingcode. In either case, this time period presents a point at which amalware scan may be performed. Thus, a write access to any of thesepages generates a “vmexit,” and control is transferred to the VMM 420.

A vmexit is a hardware-assisted virtualization mechanism which transferscontrol from the OS 430 to the VMM 420. While control is with the VMM420, the processor register states, stack pointer, and other statesrelating to execution of the unpacker code may be recorded. Once thestates are recorded and other tasks are performed (e.g., buildingheuristics data, scanning), control may be passed back to the OS 430that generated the vmexit or may be passed to an error handling routine.

At 615, the page which contains the Entry Point of the self-extractingexecutable may be identified, and permissions for that page should beset to read only (R_). After all permissions in page memory have beenset by the VMM 420, control is returned to the OS 430 at 620. Executionof the Entry Point will generate a vmexit at the Entry Point ExecutionViolation Time, as shown at 625, and the VMM 420 will gain control.Accordingly, at this point, the stack pointer value and stack contentsrepresenting the start of execution may be recorded in the heuristicsstatistics data 428 of the generic unpacker 422. The state at the startof execution is useful for building heuristics because it is the statewhich is expected by the original unpacked program. Each time control ispassed to the VMM 420 after a violation time, a scan of memory may alsobe performed by scanner 426 based on heuristics analysis by heuristicsengine 424, as shown at 630. At 635, where sections are marked aswritable and executable (RWX) in the binary header, permissions of readand execute but no write (R_X) are assigned. After page permissions arechanged, control may be returned to the OS 430.

When the unpacker stub of the self-extracting executable beginsexecution, there may be multiple page access violations, each of whichcause control to be passed to the VMM 420. At each of these times,heuristic statistics 428 may be gathered (625), scans may be performed(630), and permissions may be adjusted and control returned to the OS(635). Examples of violations and actions based on the violations willbe discussed in greater detail below. In certain situations, whilecontrol is at VMM 420, the generic unpacker 422 may determine through ascan that a known packing algorithm for a packing iteration of aniteratively packed executable is recognized. If so, the generic unpacker422 may proceed by unpacking the contents itself rather than bycontrolled execution. If a subsequent packing iteration is unrecognized,the generic unpacker 422 may return to controlled execution of theexecutable.

FIG. 6B shows a state diagram 650 demonstrating the state transitionsduring execution of an executable. State 1 (655) represents Binary LoadTime, which has been described above. After setting permissions andrecording the state at Binary Load Time, a vmexit at the Entry PointExecution Violation Time results in entering State 2 (660), at whichtime the image entry point state is recorded. Control is returned to theOS, and execution continues normally at State 3 (665).

At a Write Violation Time, State 5 (675) is entered, and the VMM 420transfers control to the generic unpacker 422. The generic unpacker 422updates its internal bookkeeping heuristic statistical data 428. Thismay include the number of pages of the particular section that are beingwritten on to, the number of times this particular page has beingwritten, etc. The generic unpacker 422 also makes the particular pagewritable (+W) for the OS 430 but removes execute (−X) access. At State 6(680), based on heuristics, a heuristic engine 424 of the genericunpacker 422 may trigger a scan in memory of malware signatures. If nosignature is found or if no scan is performed based on heuristics, thegeneric unpacker 422 determines that unpacking is still not complete,and control is passed to OS 430 and execution continues at State 3(665). If a malware signature is found, then execution of the executablemay be forcefully terminated, as shown at the transition to State 7(685).

Similarly, at the Page Execution Violation Time, State 4 (670) isentered, and the VMM 420 transfers control to the generic unpacker 422.The generic unpacker 422 updates its internal bookkeeping heuristicstatistical data 428, which may include the number of pages of theparticular section that have violated execution access permissions, thenumber of times the particular page has violated execution accesspermissions, etc. The generic unpacker 422 also makes the particularpage executable (+X) for the OS 430 but removes write (−W) access. Ascan may be performed at State 6 (680), and execution may continue atState 3 (665) or be terminated at State 7 (685).

Scanning for signatures may be performed at each page violation time,but heuristics may be used to optimize and conserve processing resourcesto avoid scanning each time a page violation occurs. For example, ateach Page Execution Violation Time, one heuristic that may be used is tocompare the stack pointer and the stack contents to their originalvalues. If the stack pointer value is equal to the stack pointer valuerecorded at the Entry Point Execution Violation Time (i.e., State 2(660)), and the stack contents are also the same, there is a possibilitythat the OEP is about to execute. The stack pointer and stack contentsreturning to their original Entry Point Execution Violation Time valuesmay indicate that the unpacker processes have run to completion andscanning should be performed.

Another heuristic may be to locate the section from which the pageexecution violation was trapped. If all the pages of this section havebeen written to, and this is first execution violation from this sectionsubsequent to the writing, then there may be a high probability that allthe pages in this section have been unpacked by unpacker stub, andcontrol is being transferred to the OEP. At this point, scanning shouldbe performed. In another situation, if all the pages of a particularsection have not been written to, and the first execution violation istrapped from the section, then there is still a probability that thesection is fully unpacked, and scanning should be performed. Othertechniques may be used to recognize completion of the unpacking of theexecutable.

Heuristics may also be employed at a Page Write Violation Time. If at awrite violation, the page from which the write violation originated isthe last page of a particular section that is being written to, there isa high probability that the section is completely unpacked. At thispoint, scanning should be performed.

The above example heuristics are based on the identification ofsituations in which control may be being passed to the OEP of theunpacked binary. Other heuristics may be employed as desired. Forexample, additional heuristics may be built based at least in part onspecific characteristics of other packers, such as signatures of packercode, characteristics of the execution of other packers, etc. Theheuristics described above may be combined with these other heuristics,or the other heuristics may replace the example heuristics describedabove. Where new heuristics are needed to identify certain packers, anupdate of new heuristic mechanisms would likely be faster and moreefficient than writing a new unpacker for an antivirus program.

As explained above, comparing a virus signature to a binary ispreferably performed after that binary is fully unpacked but before thatbinary has begun to execute. In this way, the binary executable is notobfuscated and hidden through a packing process and can be compared withvirus signature files directly in memory while preventing the binaryfrom executing before the malware scanning is performed. Further, othermalware detection techniques in addition to, or instead of, signaturescanning may be performed. In summary, execution of the unpacking codeis allowed, but execution is prevented or interrupted before theuncompressed, unpacked binary begins execution of the Original EntryPoint.

FIG. 7 illustrates an example of a heuristic for determining the startof execution of the Original Entry Point, and the subsequent preventionof its execution. In FIG. 7, four states 710, 720, 730, and 740 of theheuristic are shown. Each state shows the permissions set for OS memorypages P1, P2, P3, P4, and P5 for a given set of memory page accesses ata point in time during execution. As will be described in detail below,the progression of the execution leads to the changes in states. Memorypages P1-P4 form the virtual code section 125, and page P5 forms thepacker code section 130. In this example, the unpacker code section 130only occupies one page, i.e. page P5. The unpacker stub from page P5will unpack code into pages P1-P4. The permissions for pages P1-P5 aredefined by the binary header 120 (not shown in FIG. 6B).

At initial state 710, the permissions for the pages are set differentlyfrom the definitions in the binary header. Thus, while the binary headerspecifies that page P5, which contains the executable unpacker stub,should have execute and write permissions, page P5 is set to allow readand write permissions but not the execute permission at initial state710. Accordingly, page P5 is represented as “RW_” at initial state 660,and execution will trigger a vmexit. Similarly, while pages P1-P4 aredefined in the binary header as having read, write, and executepermissions, pages P1-P4 are set to allow read and execute permissionsbut not the write permission at initial state 660. Accordingly, pagesP1-P4 are represented as “R_X” at initial state 660.

When code in page P5 first attempts to execute, a vmexit will betriggered because page P5 does not have execution permissions set. Ifmultiple pages are set to write access, then the first page of thosepages to trigger a vmexit may be identified as the Entry Point ExecutionViolation Time. In this example, with page P5 being the only such page,the first attempt to execute code stored anywhere in page P5 is anindication of the Entry Point Execution Violation Time. Afterappropriate processing is completed, as described above (such asrecording the stack pointer, contents, and other state information),page P5 permissions are changed to add execution permissions (i.e.,enabling ‘X’) but remove write permissions (i.e., disabling ‘W’). Thisis shown at second state 720.

Looking at pages P1-P4, these pages have started out without writepermissions. Subsequently, when a write is attempted at any of pagesP1-P4, a vmexit is triggered. A write anywhere in one of these pages isalso an indication that the code being written is meant to be executedsometime later. In the example, a write to page P1 is attempted, and avmexit is triggered. At state 730, page P1 permissions have been changedto add write permissions (i.e., enabling ‘W’) but remove executepermissions (i.e., disabling ‘X’). Thus, any subsequent executionattempt at page P1 will trigger a vmexit, returning control again to theVMM 420. Once the permissions for P1 have been adjusted, the VMM 420returns control to the OS 430, which, in turn, returns control to theunpacker stub. At this point, the original write instruction (whichtriggered the vmexit) may be allowed to complete, and the unpacker stubwrites to page P1.

In this manner, pages P1-P4 may be written to a number of times. Eachtime a first write attempt at a page occurs, a vmexit will be triggered,and the permissions will be changed as described above with respect topage P1. As noted above, at each of these points, heuristic statistics428 may be gathered before permissions are changed and control isreturned to the OS 430. State 740 shows a situation in which each ofpages P1-P4 have been attempted to be written to, a vmexit wasgenerated, and permissions were changed to remove execute access andpermit write access. As noted above, at various states, based onheuristic analysis, scans may be performed to determine whether asignature can be recognized.

At state 690, in the example, assume that all writing (i.e., unpacking)has been completed. At this point, the unpacker code stub from P5completes execution, and attempts to transfer control to the OriginalEntry Point (which resides somewhere in P1-P4) of the unpackedexecutable. Assume that page P3 has the Original Entry Point (OEP) forthe original unpacked executable binary, and page P5 attempts totransfer control to it. An execution attempt anywhere in page P3generates a vmexit. At this point, control is transferred to the VMM420, and the heuristic generic unpacker engine gets control. The genericunpacker engine at this point can determine that pages P1-P4 have allbeen written to, and that this is the first execution violation in thissection. Accordingly, as noted above, there is a high chance that theOEP is being executed and hence the whole section should be scanned.

If, at this stage, pages P1-P4 contain unpacked malware, the malware maybe identified by the signature scan. If, on the other hand, nothing isfound, page P3 permissions may be marked to allow execution access anddisallow write access. Execution may continue until a vmexit triggersagain, and a new heuristic criterion is met. Eventually, if no furtherheuristic is triggered or pages P1-P4 complete execution after multipleiterations of unpacking without any identification of malware, it may bedetermined that the unpacked executable is not malware (or, at leastthat a malware signature is not known for the unpacked binary).

EXAMPLES

The following examples pertain to further embodiments of thisdisclosure.

1. A method of unpacking a self-extracting executable to detect malwareby loading a self-extracting executable into memory, the self-extractingexecutable comprising a first unpacking stub and a packed executable;allowing the first unpacking stub to unpack the packed executable intoan unpacked executable; detecting completion of the first unpacking stubusing one or more heuristics; and scanning the unpacked executable formalware.

2. The method of example 1, wherein the packed executable is aniteratively packed executable comprising one or more intermediateself-extracting executables, wherein the instructions to cause one ormore processing units to allow the first unpacking stub to unpack thepacked executable comprise instructions to cause one or more processingunits to allow the first unpacking stub to unpack the packed executableinto one of the one or more intermediate self-extracting executables;and allow the one of the one or more intermediate self-extractingexecutables to unpack successively until a final unpacking stub unpacksa final packed executable into a final unpacked executable, wherein theinstructions to cause one or more processing units to scan the unpackedexecutable for malware comprise instructions to cause one or moreprocessing units to scan the final unpacked executable for malware.

3. The method of example 2, wherein scanning the unpacked executable formalware further comprises scanning at least at least one of the one ormore intermediate self-extracting executables for malware.

4. The method of example 2, wherein the final unpacked executable is notallowed to execute if malware is detected.

5. The method from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect an attempt to execute code that was previouslywritten into a memory page by the first unpacking stub.

6. The method from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect execution of an entry point of the self-extractingexecutable.

7. The method from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect writing to a memory page in which code waspreviously executed.

8. The method from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable further comprises:using hardware assisted virtualization to, after detecting the writing,pause execution of the first unpacking stub; collecting heuristicsstatistics while execution of the first unpacking stub is paused;determining whether memory should be scanned based on the heuristicsstatistics; scanning memory based upon the determination; and allowingexecution of the first unpacking stub to continue.

9. The method from any of the preceding examples, wherein scanning theunpacked executable is performed prior to execution of the unpackedexecutable.

10. The method from any of the preceding examples, wherein the packedexecutable was packed using an unknown or undetectable packingalgorithm.

11. The method from any of the preceding examples, wherein the one ormore heuristics comprise a heuristic to compare a stack pointer valueand stack contents recorded prior to detecting completion of the firstunpacking stub with a stack pointer value and stack contents recordedprior to allowing the first unpacking stub to begin unpacking the packedexecutable.

12. The method from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprisescontrolling execution of the first unpacking stub while allowing thefirst unpacking stub to unpack the packed executable into an unpackedexecutable.

13. A system configured to unpack a self-extracting executable to detectmalware, comprising: a memory and one or more processing units,communicatively coupled to the memory, wherein the memory storesinstructions to cause the one or more processing units to: load aself-extracting executable into memory, the self-extracting executablecomprising a first unpacking stub and a packed executable; allowing thefirst unpacking stub to unpack the packed executable into an unpackedexecutable; detect completion of the first unpacking stub using one ormore heuristics; and scan the unpacked executable for malware.

14. The system of example 13, wherein the packed executable is aniteratively packed executable comprising one or more intermediateself-extracting executables, wherein the instructions to cause one ormore processing units to allow the first unpacking stub to unpack thepacked executable comprise instructions to cause one or more processingunits to allow the first unpacking stub to unpack the packed executableinto one of the one or more intermediate self-extracting executables;and allow the one of the one or more intermediate self-extractingexecutables to unpack successively until a final unpacking stub unpacksa final packed executable into a final unpacked executable, wherein theinstructions to cause one or more processing units to scan the unpackedexecutable for malware comprise instructions to cause one or moreprocessing units to scan the final unpacked executable for malware.

15. The system of example 14, wherein scanning the unpacked executablefor malware further comprises scanning at least at least one of the oneor more intermediate self-extracting executables for malware.

16. The system of example 14, wherein the final unpacked executable isnot allowed to execute if malware is detected.

17. The system from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect an attempt to execute code that was previouslywritten into a memory page by the first unpacking stub.

18. The system from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect execution of an entry point of the self-extractingexecutable.

19. The system from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect writing to a memory page in which code waspreviously executed.

20. The system from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable further comprises:using hardware assisted virtualization to, after detecting the writing,pause execution of the first unpacking stub; collecting heuristicsstatistics while execution of the first unpacking stub is paused;determining whether memory should be scanned based on the heuristicsstatistics; scanning memory based upon the determination; and allowingexecution of the first unpacking stub to continue.

21. The system from any of the preceding examples, wherein scanning theunpacked executable is performed prior to execution of the unpackedexecutable.

22. The system from any of the preceding examples, wherein the packedexecutable was packed using an unknown or undetectable packingalgorithm.

23. The system from any of the preceding examples, wherein the one ormore heuristics comprise a heuristic to compare a stack pointer valueand stack contents recorded prior to detecting completion of the firstunpacking stub with a stack pointer value and stack contents recordedprior to allowing the first unpacking stub to begin unpacking the packedexecutable.

24. The system from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprisescontrolling execution of the first unpacking stub while allowing thefirst unpacking stub to unpack the packed executable into an unpackedexecutable.

25. A computer-readable medium comprising computer executableinstructions stored thereon to cause one or more processing units to:load a self-extracting executable into memory, the self-extractingexecutable comprising a first unpacking stub and a packed executable;allow the first unpacking stub to unpack the packed executable into anunpacked executable; detect completion of the first unpacking stub usingone or more heuristics; and scan the unpacked executable for malware.

26. The computer-readable medium of example 25, wherein the packedexecutable is an iteratively packed executable comprising one or moreintermediate self-extracting executables, wherein the instructions tocause one or more processing units to allow the first unpacking stub tounpack the packed executable comprise instructions to cause one or moreprocessing units to allow the first unpacking stub to unpack the packedexecutable into one of the one or more intermediate self-extractingexecutables; and allow the one of the one or more intermediateself-extracting executables to unpack successively until a finalunpacking stub unpacks a final packed executable into a final unpackedexecutable, wherein the instructions to cause one or more processingunits to scan the unpacked executable for malware comprise instructionsto cause one or more processing units to scan the final unpackedexecutable for malware.

27. The computer-readable medium of example 26, wherein the instructionsto cause one or more processing units to scan the unpacked executablefor malware further comprise instructions to cause one or moreprocessing units to scan at least one of the one or more intermediateself-extracting executables for malware.

28. The computer-readable medium of example 26, wherein the finalunpacked executable is not allowed to execute if malware is detected.

29. The computer-readable medium from any of the preceding examples,wherein the instructions to cause one or more processing units to allowthe first unpacking stub to unpack the packed executable compriseinstructions to cause one or more processing units to use hardwareassisted virtualization to control memory page access permissions todetect an attempt to execute code that was previously written into amemory page by the first unpacking stub.

30. The computer-readable medium from any of the preceding examples,wherein the instructions to cause one or more processing units to allowthe first unpacking stub to unpack the packed executable compriseinstructions to cause one or more processing units to use hardwareassisted virtualization to control memory page access permissions todetect execution of an entry point of the self-extracting executable.

31. The computer-readable medium from any of the preceding examples,wherein the instructions to cause one or more processing units to allowthe first unpacking stub to unpack the packed executable compriseinstructions to cause one or more processing units to use hardwareassisted virtualization to control memory page access permissions todetect writing to a memory page in which code was previously executed.

32. The computer-readable medium from any of the preceding examples,wherein the instructions to cause one or more processing units to allowthe first unpacking stub to unpack the packed executable furthercomprise instructions to cause one or more processing units to: usehardware assisted virtualization to, after detecting the writing, pauseexecution of the first unpacking stub; collect heuristics statisticswhile execution of the first unpacking stub is paused; determine whethermemory should be scanned based on the heuristics statistics; scan memorybased upon the determination; and allow execution of the first unpackingstub to continue.

33. The computer-readable medium from any of the preceding examples,wherein scanning the unpacked executable is performed prior to executionof the unpacked executable.

34. The computer-readable medium from any of the preceding examples,wherein the packed executable was packed using an unknown orundetectable packing algorithm.

35. The computer-readable medium from any of the preceding examples,wherein the one or more heuristics comprise a heuristic to compare astack pointer value and stack contents recorded prior to detectingcompletion of the first unpacking stub with a stack pointer value andstack contents recorded prior to allowing the first unpacking stub tobegin unpacking the packed executable.

36. The computer-readable medium from any of the preceding examples,wherein the instructions to cause one or more processing units to allowthe first unpacking stub to unpack the packed executable compriseinstructions to cause one or more processing units to control executionof the first unpacking stub while allowing the first unpacking stub tounpack the packed executable into an unpacked executable.

37. A device configured to unpack a self-extracting executable to detectmalware, comprising modules to: load a self-extracting executable intomemory, the self-extracting executable comprising a first unpacking stuband a packed executable; allowing the first unpacking stub to unpack thepacked executable into an unpacked executable; detect completion of thefirst unpacking stub using one or more heuristics; and scan the unpackedexecutable for malware.

38. The device of example 37, wherein the packed executable is aniteratively packed executable comprising one or more intermediateself-extracting executables, wherein the instructions to cause one ormore processing units to allow the first unpacking stub to unpack thepacked executable comprise instructions to cause one or more processingunits to allow the first unpacking stub to unpack the packed executableinto one of the one or more intermediate self-extracting executables;and allow the one of the one or more intermediate self-extractingexecutables to unpack successively until a final unpacking stub unpacksa final packed executable into a final unpacked executable, wherein theinstructions to cause one or more processing units to scan the unpackedexecutable for malware comprise instructions to cause one or moreprocessing units to scan the final unpacked executable for malware.

39. The device of example 38, wherein scanning the unpacked executablefor malware further comprises scanning at least at least one of the oneor more intermediate self-extracting executables for malware.

40. The device of example 38, wherein the final unpacked executable isnot allowed to execute if malware is detected.

41. The device from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect an attempt to execute code that was previouslywritten into a memory page by the first unpacking stub.

42. The device from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect execution of an entry point of the self-extractingexecutable.

43. The device from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprises usinghardware assisted virtualization to control memory page accesspermissions to detect writing to a memory page in which code waspreviously executed.

44. The device from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable further comprises:using hardware assisted virtualization to, after detecting the writing,pause execution of the first unpacking stub; collecting heuristicsstatistics while execution of the first unpacking stub is paused;determining whether memory should be scanned based on the heuristicsstatistics; scanning memory based upon the determination; and allowingexecution of the first unpacking stub to continue.

45. The device from any of the preceding examples, wherein scanning theunpacked executable is performed prior to execution of the unpackedexecutable.

46. The device from any of the preceding examples, wherein the packedexecutable was packed using an unknown or undetectable packingalgorithm.

47. The device from any of the preceding examples, wherein the one ormore heuristics comprise a heuristic to compare a stack pointer valueand stack contents recorded prior to detecting completion of the firstunpacking stub with a stack pointer value and stack contents recordedprior to allowing the first unpacking stub to begin unpacking the packedexecutable.

48. The device from any of the preceding examples, wherein allowing thefirst unpacking stub to unpack the packed executable comprisescontrolling execution of the first unpacking stub while allowing thefirst unpacking stub to unpack the packed executable into an unpackedexecutable.

49. A device configured to unpack a self-extracting executable to detectmalware, comprising: means for loading a self-extracting executable intomemory, the self-extracting executable comprising a first unpacking stuband a packed executable; means for allowing the first unpacking stub tounpack the packed executable into an unpacked executable; means fordetecting completion of the first unpacking stub using one or moreheuristics, independent of knowledge of the first unpacking stub; andmeans for scanning the unpacked executable for malware.

50. The device of preceding example, wherein the packed executablecomprises a sequence of self-extracting executables, each member of thesequence except the last comprising an unpacking stub and a successorself-extracting executable, wherein the last member comprises a finalunpacking stub and a final packed executable, wherein the means forallowing the first unpacking stub to unpack the packed executablecomprise: means for allowing the first unpacking stub to unpack thepacked executable into a first member of the sequence of self-extractingexecutables; and means for allowing each member of the sequence ofself-extracting executables to unpack the successor self-extractingexecutable until the final unpacking stub unpacks the final packedexecutable into a final unpacked executable, wherein means for scanningthe unpacked executable for malware comprise means for scanning thefinal unpacked executable for malware.

The specifics in the examples above may be used anywhere in one or moreembodiments. For instance, all optional features of the apparatus asdescribed above may also be implemented as methods or processes asdescribed herein. Further, the examples above may be implemented in onedevice or multiple devices in a system.

The above described examples and embodiments may be implemented ascomputer-executable instructions or code in embodied in acomputer-readable storage medium. The computer-executable instructionsor computer program products as well as any data created and used duringimplementation of the disclosed technologies can be stored on one ormore tangible computer-readable storage media, such as optical mediadiscs (e.g., DVDs, CDs), volatile memory components (e.g., DRAM, SRAM),or non-volatile memory components (e.g., flash memory, disk drives).Computer-readable storage media can be contained in computer-readablestorage devices such as solid-state drives, USB flash drives, and memorymodules

In the foregoing description, for purposes of explanation, numerousspecific details are set forth in order to provide a thoroughunderstanding of the disclosed embodiments. It will be apparent,however, to one skilled in the art that the disclosed embodiments may bepracticed without these specific details. In other instances, structureand devices are shown in block diagram form in order to avoid obscuringthe disclosed embodiments. References to numbers without subscripts orsuffixes are understood to reference all instance of subscripts andsuffixes corresponding to the referenced number. Moreover, the languageused in this disclosure has been principally selected for readabilityand instructional purposes, and may not have been selected to delineateor circumscribe the inventive subject matter, resort to the claims beingnecessary to determine such inventive subject matter. Reference in thespecification to “one embodiment” or to “an embodiment” means that aparticular feature, structure, or characteristic described in connectionwith the embodiments is included in at least one disclosed embodiment,and multiple references to “one embodiment” or “an embodiment” shouldnot be understood as necessarily all referring to the same embodiment.

It is also to be understood that the above description is intended to beillustrative, and not restrictive. For example, above-describedembodiments may be used in combination with each other and illustrativeprocess steps may be performed in an order different than shown. Manyother embodiments will be apparent to those of skill in the art uponreviewing the above description. The scope of the invention thereforeshould be determined with reference to the appended claims, along withthe full scope of equivalents to which such claims are entitled. In theappended claims, terms “including” and “in which” are used asplain-English equivalents of the respective terms “comprising” and“wherein.”

What is claimed is:
 1. A non-transitory computer-readable medium onwhich is stored software for unpacking a self-extracting executable,comprising instructions that when executed cause one or more processingunits to: load a self-extracting executable into memory, theself-extracting executable comprising a first unpacking stub and apacked executable; allow the first unpacking stub to unpack the packedexecutable into an unpacked executable; detect an attempt to write to amemory page in which code was previously executed, by controlling memorypage access permissions using hardware assisted virtualization; detectcompletion of unpacking the packed executable by the first unpackingstub using one or more heuristics; and scan the unpacked executable formalware, wherein the one or more heuristics comprise: determiningwhether a write to a memory page that generates a page write exceptionis a write to a last page of a section of memory pages.
 2. Thenon-transitory computer-readable medium of claim 1, wherein the packedexecutable is an iteratively packed executable comprising one or moreintermediate self-extracting executables, wherein the instructions tocause one or more processing units to allow the first unpacking stub tounpack the packed executable comprise instructions to cause one or moreprocessing units to: allow the first unpacking stub to unpack the packedexecutable into one of the one or more intermediate self-extractingexecutables; and allow the one of the one or more intermediateself-extracting executables to unpack successively until a finalunpacking stub unpacks a final packed executable into a final unpackedexecutable, wherein the instructions to cause one or more processingunits to scan the unpacked executable for malware comprise instructionsto cause one or more processing units to scan the final unpackedexecutable for malware.
 3. The non-transitory computer-readable mediumof claim 2, wherein the instructions to cause one or more processingunits to scan the unpacked executable for malware further compriseinstructions to cause one or more processing units to scan at least oneof the one or more intermediate self-extracting executables for malware.4. The non-transitory computer-readable medium of claim 2, wherein thefinal unpacked executable is not allowed to execute if malware isdetected.
 5. The non-transitory computer-readable medium of claim 1,wherein the instructions to cause one or more processing units to allowthe first unpacking stub to unpack the packed executable compriseinstructions to cause one or more processing units to use hardwareassisted virtualization to control memory page access permissions todetect an attempt to execute code that was previously written into amemory page by the first unpacking stub.
 6. The non-transitorycomputer-readable medium of claim 5, wherein the instructions to causeone or more processing units to allow the first unpacking stub to unpackthe packed executable further comprise instructions to cause one or moreprocessing units to: use hardware assisted virtualization to, afterdetecting the attempt, pause execution of the first unpacking stub;collect heuristics statistics while execution of the first unpackingstub is paused; determine whether memory should be scanned based on theheuristics statistics; scan memory based upon the determination; andallow execution of the first unpacking stub to continue.
 7. Thenon-transitory computer-readable medium of claim 1, wherein theinstructions to cause one or more processing units to allow the firstunpacking stub to unpack the packed executable comprise instructions tocause one or more processing units to use hardware assistedvirtualization to control memory page access permissions to detectexecution of an entry point of the self-extracting executable.
 8. Thenon-transitory computer-readable medium of claim 1, wherein the one ormore heuristics further comprise: determining whether an attempt toexecute code is a first attempt to execute code from a code sectionincluding the memory page after writing all pages of the code section.9. The non-transitory computer-readable medium of claim 8, wherein theinstructions to cause one or more processing units to allow the firstunpacking stub to unpack the packed executable further compriseinstructions to cause one or more processing units to: use hardwareassisted virtualization to, after detecting the writing, pause executionof the first unpacking stub; collect heuristics statistics whileexecution of the first unpacking stub is paused; determine whethermemory should be scanned based on the heuristics statistics; scan memorybased upon the determination; and allow execution of the first unpackingstub to continue.
 10. The non-transitory computer-readable medium ofclaim 1, wherein scanning the unpacked executable is performed prior toexecution of the unpacked executable.
 11. The non-transitorycomputer-readable medium of claim 1, wherein the packed executable waspacked using an unknown or undetectable packing algorithm.
 12. Thenon-transitory computer-readable medium of claim 1, wherein the one ormore heuristics comprise a heuristic to compare a stack pointer valueand stack contents recorded prior to detecting completion of the firstunpacking stub with a stack pointer value and stack contents recordedprior to allowing the first unpacking stub to begin unpacking the packedexecutable.
 13. The non-transitory computer-readable medium of claim 1,wherein the instructions to cause one or more processing units to allowthe first unpacking stub to unpack the packed executable compriseinstructions to cause one or more processing units to control executionof the first unpacking stub while allowing the first unpacking stub tounpack the packed executable into an unpacked executable.
 14. A methodof unpacking a self-extracting executable to detect malware, comprising:loading, using a processor, a self-extracting executable into memory,the self-extracting executable comprising a first unpacking stub and apacked executable; allowing the first unpacking stub to unpack thepacked executable into an unpacked executable; detecting an attempt towrite to a memory page in which code was previously executed, bycontrolling memory page access permissions using hardware assistedvirtualization; detecting, using a processor, completion of the firstunpacking stub using one or more heuristics; and scanning the unpackedexecutable for malware, wherein the one or more heuristics comprise:determining whether a write to a memory page that generates a page writeexception is a write to a last page of a section of memory pages. 15.The method of claim 14, wherein the packed executable is an iterativelypacked executable comprising one or more intermediate self-extractingexecutables, wherein allowing the first unpacking stub to unpack thepacked executable comprises: allowing the first unpacking stub to unpackthe packed executable into one of the one or more intermediateself-extracting executables; and allowing the one of the one or moreintermediate self-extracting executables to unpack successively until afinal unpacking stub unpacks a final packed executable into a finalunpacked executable, and wherein scanning the unpacked executable formalware comprises scanning the final unpacked executable for malware.16. The method of claim 15, wherein scanning the unpacked executable formalware further comprises scanning at least one of the one or moreintermediate self-extracting executables for malware.
 17. The method ofclaim 14, wherein allowing the first unpacking stub to unpack the packedexecutable comprises using hardware assisted virtualization to controlmemory page access permissions to detect an attempt to execute code thatwas previously written into a memory page by the first unpacking stub.18. The method of claim 17, wherein allowing the first unpacking stub tounpack the packed executable further comprises: using hardware assistedvirtualization to, after detecting the attempt, pause execution of thefirst unpacking stub; collecting heuristics statistics while executionof the first unpacking stub is paused; determining whether memory shouldbe scanned based on the heuristics statistics; scanning memory basedupon the determination; and allowing execution of the first unpackingstub to continue.
 19. The method of claim 14, wherein scanning theunpacked executable is performed prior to execution of the unpackedexecutable.
 20. The method of claim 14, wherein the packed executablewas packed using an unknown or undetectable packing algorithm.
 21. Asystem configured to unpack a self-extracting executable to detectmalware, comprising: a memory; and one or more processing units,communicatively coupled to the memory, wherein the memory storesinstructions to cause the one or more processing units to: load aself-extracting executable into memory, the self-extracting executablecomprising a first unpacking stub and a packed executable; allow thefirst unpacking stub to unpack the packed executable into an unpackedexecutable; detect an attempt to write to a memory page in which codewas previously executed, by controlling memory page access permissionsusing hardware assisted virtualization; detect completion of the firstunpacking stub using one or more heuristics; and scan the unpackedexecutable for malware, wherein the one or more heuristics comprise:determining whether a write to a memory page that generates a page writeexception is a write to a last page of a section of memory pages. 22.The system of claim 21, wherein the packed executable is an iterativelypacked executable comprising one or more intermediate self-extractingexecutables, wherein the instructions to cause one or more processingunits to allow the first unpacking stub to unpack the packed executablecomprise instructions to cause one or more processing units to: allowthe first unpacking stub to unpack the packed executable into one of theone or more intermediate self-extracting executables; and allow the oneof the one or more intermediate self-extracting executables to unpacksuccessively until a final unpacking stub unpacks a final packedexecutable into a final unpacked executable, wherein the instructions tocause one or more processing units to scan the unpacked executable formalware comprise instructions to cause one or more processing units toscan the final unpacked executable for malware.
 23. The system of claim22, wherein the instructions to cause one or more processing units toscan the unpacked executable for malware further comprise instructionsto cause one or more processing units to scan at least one of the one ormore intermediate self-extracting executables for malware.
 24. Thesystem of claim 21, wherein the instructions to cause one or moreprocessing units to allow the first unpacking stub to unpack the packedexecutable comprise instructions to cause one or more processing unitsto use hardware assisted virtualization to control memory page accesspermissions to detect an attempt to execute code that was previouslywritten into a memory page by the first unpacking stub.
 25. The systemof claim 21, wherein the instructions to cause one or more processingunits to allow the first unpacking stub to unpack the packed executablefurther comprise instructions to cause one or more processing units to:use hardware assisted virtualization to, after detecting the attempt,pause execution of the first unpacking stub; collect heuristicsstatistics while execution of the first unpacking stub is paused;determine whether memory should be scanned based on the heuristicsstatistics; scan memory based upon the determination; and allowexecution of the first unpacking stub to continue.